package pATT.profilingAlgorithm.PersonalSearcher;
/***************************************************************************
 *                                 AsciiDocument                           *
 *                       initial version by: Travis Bauer                  *
 *                      copyright (C) 2001 IGLU Research Group             *
 *                            trbauer@indiana.edu                          *
 ***************************************************************************/
/***************************************************************************
 * The licence for this code is included in LICENSE.txt.  If you did not   *
 * get this file with this distribution, request a copy from               *
 * iglu@cs.indiana.edu                                                     *
 ***************************************************************************/


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.Serializable;



/**
 * Represents a simple ascii document with no highlighted text.
 * The full content (except single-character words) is considered indexible.
 *
 * @author <a href="mailto:trbauer@indiana.edu">Travis Bauer</a>
 * @author <a href="mailto:rscherle@indiana.edu">Ryan Scherle</a>
 * @version 1.0
 * @since 1.0
 * @see AbstractDocument
 */
public class ASCIIDocument extends AbstractDocument implements Serializable {

  /////////////////////////////////////////////////////////////////

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public ASCIIDocument(String path, String language){
	
		String input;
		StringBuffer text = new StringBuffer();

		try{
			BufferedReader buffer;
		 	buffer= new BufferedReader(new FileReader(path));
	  	while ((input = buffer.readLine()) != null) { 
	  		text.append(input);
	  		text.append(" ");
			}
	 	  buffer.close();
	
		}catch(IOException e) {}

   		setFullContent(text.toString());
		setIndexibleContent(StringTools.removeDelimiters(text.toString()));
  }

  /////////////////////////////////////////////////////////////////
  public String getIndexibleContent()
  {
    String s = super.getIndexibleContent();
    if (s == null)
      {
	setIndexibleContent(StringTools.removeDelimiters(getFullContent()));
	s = super.getIndexibleContent();
      } 
    return s;
  }

  /////////////////////////////////////////////////////////////////
  /**
     Returns text that is highlighted in some manner.
     In a basic ascii document, no text is highlighted, so this procedure
     only returns empty strings.
   */
  public String getStylizedText(int style) {
    return new String();
  }
}
